﻿using System;
using System.Web;
using System.Web.Security;

namespace HelfenHelfen.Web.Forms.Site.Utility {
   public static class UserProfile {
      public class Personal {
         public static System.String FirstName {
            get {
               return HttpContext.Current.Profile.GetPropertyValue("FirstName") as System.String;
            }
            set { HttpContext.Current.Profile.SetPropertyValue("FirstName", value); }
         }

         public static System.String LastName {
            get {
               return HttpContext.Current.Profile.GetPropertyValue("LastName") as System.String;
            }
            set { HttpContext.Current.Profile.SetPropertyValue("LastName", value); }
         }

         public static System.String Phone {
            get {
               return HttpContext.Current.Profile.GetPropertyValue("PhoneNo") as System.String;
            }
            set { HttpContext.Current.Profile.SetPropertyValue("PhoneNo", value); }
         }

         public class Address {
            public static System.String Street {
               get {
                  return HttpContext.Current.Profile.GetPropertyValue("Street") as System.String;
               }
               set { HttpContext.Current.Profile.SetPropertyValue("Street", value); }
            }

            public static System.String ZipCode {
               get {
                  return HttpContext.Current.Profile.GetPropertyValue("PostalCode") as System.String;
               }
               set { HttpContext.Current.Profile.SetPropertyValue("PostalCode", value); }
            }

            public static System.String City {
               get {
                  return HttpContext.Current.Profile.GetPropertyValue("City") as System.String;
               }
               set { HttpContext.Current.Profile.SetPropertyValue("City", value); }
            }

            public static System.String CountryCode {
               get {
                  return HttpContext.Current.Profile.GetPropertyValue("CountryCode") as System.String;
               }
               set { HttpContext.Current.Profile.SetPropertyValue("CountryCode", value); }
            }
         }
         
         public static void Save() {
            HttpContext.Current.Profile.Save();
         }

         public static bool IsAuthenticated {
            get { return HttpContext.Current.User.Identity.IsAuthenticated; }
         }

         public static Guid UserId {
            get { return (Guid)Membership.GetUser().ProviderUserKey; }
         }

         public static string Email {
            get { return Membership.GetUser().Email; }
         }

         public static DateTime DateCreated {
            get { return Membership.GetUser().CreationDate; }
         }

         public static string UserName {
            get { return Membership.GetUser().UserName; }
         }
      }
   }
}